<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	template="/WEB-INF/templates/default.xhtml"
 	xmlns:sec="http://www.springframework.org/security/facelets/tags">  
	<ui:define name="content">
		<!-- Formulário de Pesquisa -->
		<h:form id="frmPesquisa" styleClass="form-horizontal" prependId="false">
			<p:outputPanel id="panelPesquisa">
				<fieldset>
					<legend>#{messages.TITLE_RELATORIO}</legend>
	
					<!-- Campos de Pesquisa -->
					<div class="control-group">
						<h:outputLabel for="horaInicialSearch" value="#{messages.LABEL_DATA_INICIO}:" styleClass="control-label"/>
		               	<div class="controls">
							<p:calendar id="horaInicialSearch" value="#{relatorioController.dataInicial}" showOn="button"
								pattern="dd/MM/yyyy" locale="pt"/>
						</div>
					</div>

					<div class="control-group">
						<h:outputLabel for="horaFinalSearch" value="#{messages.LABEL_DATA_FIM}:" styleClass="control-label"/>
	                    <div class="controls">
							<p:calendar id="horaFinalSearch" value="#{relatorioController.dataFinal}" showOn="button"
								pattern="dd/MM/yyyy" locale="pt"/>
						</div>
					</div>
					<!--End Campos de Pesquisa -->
	
					<!-- Primeiro Grupo de botões -->
					<div class="form-actions">
						<p:commandButton id="btnPesquisar" value="#{messages.LABEL_PESQUISAR}" action="#{relatorioController.pesquisar()}"
							process="frmPesquisa" update="frmPesquisa div_botoes" styleClass="btn btn-primary"/>
							
						<p:commandButton id="btnLimpar" value="#{messages.LABEL_LIMPAR}" action="#{relatorioController.limpar()}"
							process="@this" update="frmPesquisa, div_botoes" styleClass="btn btn-primary"/>
							
						<h:panelGroup id="div_botoes" style="#{empty relatorioController.chamados ? 'display:none;' : ''}">
							<p:commandButton id="btnImprimir" value="#{messages.BTN_IMPRIMIR}" action="#{relatorioController.imprimir()}"
								immediate="true" styleClass="btn btn-primary" label="#{messages.LABEL_IMPRIMIR}" ajax="false" onclick="frmPesquisa.target='_new'" />
						</h:panelGroup>
	                </div>
	                <!--End Primeiro Grupo de botões -->
				</fieldset>
	
				<!-- Grid de dados -->
				<p:dataTable id="tblRelatorio" var="chamado" value="#{relatorioController.chamados}" rows="10" paginator="true" 
	           		style="#{empty relatorioController.chamados ? 'display:none;' : 'display:table; width: 100%;'}" styleClass="table table-bordered">

	             	<f:facet name="header">
	             		<h:outputText value="#{messages.TITLE_PESQUISAR}"/>
	     			</f:facet>

	     			<p:column headerText="#{messages.LABEL_DATA}" >  
	                    <h:outputText value="#{chamado.dataAbertura}">
	                    	<f:convertDateTime type="date" pattern="dd/MM/yyyy"/>
	                    </h:outputText>
	                </p:column>

					<p:column headerText="#{messages.LABEL_RESUMO}" >  
	                    <h:outputText value="#{chamado.resumo}"/>
	                </p:column>
	                
	                <p:column headerText="#{messages.LABEL_DESCRICAO_PROBLEMA}" >  
	                    <h:outputText value="#{chamado.descricao}"/>
	                </p:column>

					<p:column headerText="#{messages.LABEL_SOLICITANTE}" >
	                    <h:outputText value="#{chamado.usuarioSolicitacao.nome}"/>
	                </p:column>

					<p:column headerText="#{messages.LABEL_UNIDADE}" >  
	                    <h:outputText value="#{chamado.unidade.nome}"/>
	                </p:column>

	     			<p:column headerText="#{messages.LABEL_DEPARTAMENTO}" >  
	                    <h:outputText value="#{chamado.departamento.nome}"/>
	                </p:column>

					<p:column headerText="#{messages.LABEL_STATUS}" style="text-align: center !important;">
						 <h:outputText value="#{chamado.status}"/>
	                </p:column>
				</p:dataTable>
				<!-- End Grid de dados -->
			</p:outputPanel>
		</h:form>
		<!-- End Formulário de Pesquisa -->
	</ui:define>
</ui:composition>